var menuitems = [
	{id:1,name:'首页',url:'./index.html',target:'_top',sub:[]},
	{id:2,name:'服务示范',url:'./farms.html?type=PTYH',target:'_top',sub:[
		{id:21,name:'普通用户',url:'farms.html?type=PTYH',target:'_top'},
		{id:22,name:'种植大户',url:'farms.html?type=ZZDH',target:'_top'},
		{id:23,name:'企业',url:'farms.html?type=QYYH',target:'_top'},
		{id:24,name:'基地',url:'farms.html?type=JDYH',target:'_top'},
		{id:25,name:'合作社',url:'farms.html?type=HZSYH',target:'_top'},
		{id:26,name:'供销社',url:'farms.html?type=GXSYH',target:'_top'},
		{id:27,name:'其他',url:'farms.html?type=QT',target:'_top'},
		{id:30,name:'最美乡村',url:'farms.html?type=ZMXC',target:'_top'}
	]},
	{id:3,name:'专家联盟',url:'./experts.html?type=EXPERT',target:'_top',sub:[
		{id:31,name:'粮油专家',url:'experts.html?type=EXPERT',target:'_top'},
		{id:32,name:'水果专家',url:'experts.html?type=EXPERT',target:'_top'},
		{id:33,name:'蔬菜专家',url:'experts.html?type=EXPERT',target:'_top'},
		{id:33,name:'水产专家',url:'experts.html?type=EXPERT',target:'_top'}
	]},
	{id:4,name:'市场信息',url:'./market.html',target:'_top',sub:[
		{id:41,name:'杨家坪农贸',url:'',target:'_top'},
		{id:42,name:'观农贸市场',url:'',target:'_top'},
		{id:43,name:'南岸农贸市场',url:'',target:'_top'},
		{id:44,name:'三峡蔬菜市场',url:'',target:'_top'},
		{id:45,name:'双桂农贸市场',url:'',target:'_top'},
		{id:46,name:'双福农贸市场',url:'',target:'_top'},
		{id:47,name:'永川农贸市场',url:'',target:'_top'}
	]},
	{id:5,name:'农情农灾',url:'./agrinfo.html?type=nongqing',target:'_top',sub:[
		{id:51,name:'农情',url:'agrinfo.html?type=nongqing',target:'_top'},
		{id:52,name:'灾情',url:'agrinfo.html?type=zaiqing',target:'_top'}
	]},
	{id:6,name:'农产信息',url:'./agrproducts.html',target:'_top',sub:[
		{id:61,name:'葡萄',url:'',target:'_top'},
		{id:62,name:'柑橘',url:'',target:'_top'},
		{id:63,name:'猕猴桃',url:'',target:'_top'},
		{id:64,name:'茶叶',url:'',target:'_top'},
		{id:65,name:'榨菜',url:'',target:'_top'},
		{id:66,name:'蔬菜',url:'',target:'_top'},
		{id:67,name:'烤烟',url:'',target:'_top'},
		{id:68,name:'水产',url:'',target:'_top'},
		{id:69,name:'青花椒',url:'',target:'_top'}
	]},
	{id:7,name:'特色园区',url:'./garden.html',target:'_top',sub:[
		{id:71,name:'江津农试站',url:'',target:'_top'},
		{id:72,name:'二圣茶厂',url:'',target:'_top'},
		{id:73,name:'仰头山基地',url:'',target:'_top'},
		{id:74,name:'酉阳青花椒',url:'',target:'_top'},
		{id:75,name:'福林榨菜',url:'',target:'_top'},
		{id:76,name:'奉节脐橙',url:'',target:'_top'}
	]},
	{id:8,name:'农气服务',url:'./service.html',target:'_top',sub:[
		// {id:81,name:'农业气象监测',url:'',target:'_top'},
		// {id:82,name:'农用天气预报',url:'',target:'_top'},
		// {id:83,name:'农业气象评价',url:'',target:'_top'},
		// {id:84,name:'农业气象灾害',url:'',target:'_top'},
		// {id:85,name:'节气与农事',url:'',target:'_top'},
		// {id:86,name:'农气科普资讯',url:'',target:'_top'}
	]}
];


function initMenu(){
	
	for(var i=0;i<menuitems.length;i++){
		var html = "";
		if(i == 4){
			html += "<li class=\"m\" id=\"m"+ menuitems[i]['id'] +"\" style=\"margin-left:310px;\"><h3><a href=\""+ menuitems[i]['url'] +"\" target=\""+ menuitems[i]['target'] +"\">"+ menuitems[i]["name"] +"</a></h3>";
		}else{
			html += "<li class=\"m\" id=\"m"+ menuitems[i]['id'] +"\" ><h3><a href=\""+ menuitems[i]['url'] +"\" target=\""+ menuitems[i]['target'] +"\">"+ menuitems[i]["name"] +"</a></h3>";
		}
		
		// if(menuitems[i].sub.length > 0){
		// 	var sub = menuitems[i].sub;
		// 	html += "<ul class=\"sub\" style=\"display: none;\">";
		// 	for(var n=0;n<sub.length;n++){
		// 		html += "<li><a href=\""+ sub[n]['url'] +"\" title=\""+ sub[n]['name'] +"\" target=\""+ sub[n]['target'] +"\">"+ sub[n]['name'] +"</a></li>";
		// 	}
		// 	html += "<li class=\"lih3\"><a href=\""+ menuitems[i]['url'] +"\" target=\""+ menuitems[i]['target'] +"\">进入 "+ menuitems[i]['name'] +"</a></li>";
		// 	html += "</ul>";
		// }
		if(menuitems[i].sub.length > 0){
			var sub = menuitems[i].sub;
			html += "<ul class=\"sub\" style=\"display: none; border: 1px solid; border-radius: 5px;\">";
			for(var n=0;n<sub.length;n++){				
					html += "<li><a href=\""+ sub[n]['url'] +"\" title=\""+ sub[n]['name'] +"\" target=\""+ sub[n]['target'] +"\">"+ sub[n]['name'] +"</a></li>";
			}
			// html += "<li class=\"lih3\"><a href=\""+ menuitems[i]['url'] +"\" target=\""+ menuitems[i]['target'] +"\">进入 "+ menuitems[i]['name'] +"</a></li>";
			html += "</ul>";
		}
		html += "</li>";
		$("#menuBox").append(html);
	}
}

function changeHtml(type, param){
	localStorage.setItem("type", type);
	localStorage.setItem("param", param);
	$("#html1").attr("src", "AgriMonitor/index.html?type="+ type +"&param=" + param);
}

initMenu();
